package com.twu.bibilioteca;

/**
 * Created by IntelliJ IDEA.
 * User: dixithk
 * Date: 6/20/14
 * Time: 9:54 AM
 * To change this template use File | Settings | File Templates.
 */
public class ReturnMovie implements MenuOperations {

    UserInterface ui = new UserInterfaceApp();
    Library lib = new Library();

    public ReturnMovie(UserInterface ui, Library lib) {
        this.ui = ui;
        this.lib = lib;
    }

    @Override
    public Result action() {
        Movie movieNeedToBeReturned = lib.GiveMovieObjectFromTitle(ui.takeInputFromUserForReturnMovie());
        if(movieNeedToBeReturned!=null && (lib.isMovieAvailableForCheckOut(movieNeedToBeReturned)) )
        {


            movieNeedToBeReturned.markAsReturned();
            return new Result("Thank you for returning the movie." , true);

        }
        else
        {
            return new Result("That is not a valid movie to return." , false);
        }
    }

    @Override
    public String getName() {
        return "Return a Movie";  //To change body of implemented methods use File | Settings | File Templates.
    }


}
